// 实现可迭代接口

const obj = {
    store: ["for", "bar", "baz"],
    [Symbol.iterator]: function() {
        let index = 0;
        const that = this
        return {
            next: function () {
                const result = {
                    value: that.store[index],
                    done: index >= that.store.length
                }
                index++
                return result
            }
        }
    }
}

for (const iterator of obj) {
    console.log(iterator)
}